#include "apue.h"
void main() {
	pid_t pid;
	char buf[MAXLINE];
	int status;
	while (1) {
		printf("%%");
		if (fgets(buf, MAXLINE, stdin) == NULL)
			err_sys("fgets error");
		buf[strlen(buf) - 1] = 0;
		if ((pid = fork()) < 0) {
			err_sys("fork error");
		} else if (pid == 0) {
			execlp(buf, buf, (char*)0);
			err_ret("can not execute : %s", buf);
			exit(127);
		}
		if ((pid = waitpid(pid, &status, 0)) < 0)
			err_sys("waitpid error");
		printf("%%");
	}
	return;
}

		
		

